#include <QApplication>
#include <QWidget>
#include <QPainter>
#include <QThread>
#include <QMutex>
#include <QPushButton>
#include <QVBoxLayout>
#include <QLineEdit>
#include <QDir>
#include <rviz_common/ros_integration/ros_client_abstraction.hpp>

#include "widgets/custom_frame.h"

int main(int argc, char** argv) {
    QApplication app(argc, argv);

    qRegisterMetaType<QSharedPointer<QVariantMap>>("QSharedPointer<QVariantMap>");

    QDir configDir(QApplication::applicationDirPath());
    configDir.cdUp(); // 进入上级目录
    configDir.cd("share/gcs");
    QString rvizConfigFilePath = configDir.absoluteFilePath("gcs.rviz"); // 最终路径

    auto ros_client_abstraction = std::make_unique<rviz_common::ros_integration::RosClientAbstraction>();
    auto node = ros_client_abstraction->init(argc, argv, "rviz", false /* anonymous_name */);
    auto * mainWindow = new gcs::widgets::CustomFrame(node);
    mainWindow->setApp(&app);
    mainWindow->initialize(node, rvizConfigFilePath);
    mainWindow->show();
    return app.exec();
}
